#!/bin/bash
#name of jar package
JARNAME=test.jar

MF=mainfest

#path to jar,
#JAR="/usr/lib64/jvm/java-1.5.0-sun/bin/jar"
JAR=`which jar` 
if [ -f $MF ]
then
	rm $MF
fi


#create mainfest
echo "Main-Class: test.MyApplet" >> $MF
echo "---deleting old yar"
rm $JARNAME


echo "---creating new jar"
$JAR cmf $MF $JARNAME \
  -C ../output "test" \
  -C ../output "com" \
  -C ../ data

if [ $? -eq 0 ]
then
	$JAR i $JARNAME
	echo "---jar creation succesfull"
	echo "---jar contain $(jar tf $JARNAME| wc -l) file and is $(ls -lh $JARNAME| awk '{print $5}')"
else
	echo "jar creation faild"ja
	exit 1
fi
$JAR i $JARNAME

echo "---signing applet"
jarsigner -keystore keystorefile --storepass pnemec test.jar pnemec > /dev/null

if [ $? -eq 0 ]
then 
	echo "---signing was succesfull"
else
	echo "signing faild"
	exit 1
fi

